//
//  MyButton.m
//  Enesco
//
//  Created by laomi on 2019/1/27.
//  Copyright © 2019年 aufree. All rights reserved.
//

#import "MyButton.h"

@implementation MyButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if(self){
        self.titleLabel.font = [UIFont systemFontOfSize:16];
        
    }
    return self;
}
-(instancetype)init{
    self = [super init];
    if(self){
        self.titleLabel.font = [UIFont systemFontOfSize:16];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    UIImageView *imgV = self.imageView;
    UILabel *label = self.titleLabel;
    
    CGFloat detlaLabel = imgV.frame.size.width;
    CGFloat detlaImg = label.frame.size.width;
    self.titleEdgeInsets = UIEdgeInsetsMake(0, -detlaLabel, 0, detlaLabel);
    self.imageEdgeInsets = UIEdgeInsetsMake(0, detlaImg+6, 0, -detlaImg-6);
}
@end
